
package com.tenentia.pcmps.swm.business.implementation;

import org.apache.log4j.Logger;

import com.tenentia.pcmps.swm.Constants;
import com.tenentia.pcmps.swm.business.BusinessLogicException;
import com.tenentia.pcmps.swm.business.BusinessLogicObjectsFactory;
import com.tenentia.pcmps.swm.business.BusinessLogicObject;

/**
 * 
 * @author tEnEntia, S.L.N.E.
 * 
 */
public class BusinessLogicObjectsFactoryImpl extends BusinessLogicObjectsFactory {

	private static final Logger LOGGER = Logger.getLogger(BusinessLogicObjectsFactoryImpl.class.getPackage().getName());

	private static BusinessLogicObjectsFactoryImpl staticInstance;

	static {

		staticInstance = new BusinessLogicObjectsFactoryImpl();
	}

	private BusinessLogicObjectsFactoryImpl() {

		super();
	}

	public static BusinessLogicObjectsFactory getInstance() {

		return staticInstance;
	}

	public BusinessLogicObject createNewBusinessObject(Integer businessObjectType) throws BusinessLogicException {

		LOGGER.trace(Constants.STRING_L4J_METHOD_BEGIN);

		if (null == businessObjectType) {
			throw new BusinessLogicException("Null parameter.");
		} else {
			if (businessObjectType.equals(BusinessLogicObjectsFactory.BONUS_MANAGER)) {
				return new BonusManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.GROUPS_MANAGER)) {
				return new GroupsManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.INSURANCE_POLICIES_MANAGER)) {
				return new InsurancePoliciesManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.MARKETING_PROMOTIONS_MANAGER)) {
				return new MarketingPromotionsManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.PDF_TEMPLATES_MANAGER)) {
				return new PDFTemplatesManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.PERSONS_MANAGER)) {
				return new PersonsManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.ROLES_MANAGER)) {
				return new RolesManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.USERS_MANAGER)) {
				return new UsersManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.STATES_MANAGER)) {
				return new StatesManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.WAY_TYPES_MANAGER)) {
				return new WayTypesManagerImpl();
			}
			if (businessObjectType.equals(BusinessLogicObjectsFactory.PARAMETER_MANAGER)) {
				return new ParametersManagerImpl();
			}

			throw new BusinessLogicException("Unknown parameter.");
		}
	}
}
